#!/usr/bin/python3
# -*- coding: utf-8; tab-width: 4; indent-tabs-mode: t -*-

import os
import pwd


class FmConst:

    programName = "fpemud-os-usrman"

    libDir = os.path.join("/usr/lib64", programName)
    libexecDir = os.path.join("/usr/libexec", programName)
    dataDir = os.path.join("/usr/share", programName)

    cfgDir = os.path.join(pwd.getpwuid(os.getuid()).pw_dir, ".config/usrman")
    cacheDir = os.path.join(pwd.getpwuid(os.getuid()).pw_dir, ".cache/usrman")

    @staticmethod
    def getRunDir(sessionId):
        return os.path.join("/run", "user", str(os.getuid()), "usrman", "session-%s" % (sessionId))

    @classmethod
    def getSingletonLockFile(cls, sessionId):
        return os.path.join(cls.getRunDir(sessionId), "lock")

    @classmethod
    def getRetrieveCompositorEnvironmentVariablesSocketFile(cls, sessionId):
        return os.path.join(cls.getRunDir(sessionId), "retrieve-compositor-environment-variable.socket")

    @classmethod
    def getControlSocketFile(cls, sessionId):
        return os.path.join(cls.getRunDir(sessionId), "control.socket")

    @staticmethod
    def getTmpDir(sessionId):
        return os.path.join("/tmp", "usrman-%d" % (os.getuid()), "session-%s" % (sessionId))

    @staticmethod
    def getTmpDirOnHdd(sessionId):
        return os.path.join("/var", "tmp", "usrman-%d" % (os.getuid()), "session-%s" % (sessionId))
